using System;
using System.Collections.Generic;
using System.Text;

namespace SqlScriptCreator.Generators
{
    /// <summary>
    /// Singleton class that manages deferent types of script generators of the type <see cref="IScriptGenerator"/>.
    /// Currently there generators based on
    /// table structure and on table data. These are managed in two separate lists and 
    /// can be returned to display the list of generators to the user.
    /// </summary>
    public class ScriptGeneratorManager
    {

        private static ScriptGeneratorManager _instance = null;
        private List<IScriptGenerator> _tableStructureBasedScripts;
        private List<IScriptGenerator> _tableDataBasedScripts;

        /// <summary>
        /// Initilizes the ScriptGeneratorManager and creates Instances of the different
        /// script genrators which are stored in internal lists.
        /// </summary>
        public ScriptGeneratorManager()
        {
            _tableStructureBasedScripts = new List<IScriptGenerator>();
            _tableStructureBasedScripts.Add(new CursorGenerator());
            _tableStructureBasedScripts.Add(new InsertTableVariableGenerator());
            _tableStructureBasedScripts.Add(new InsertTempTableGenerator());
            _tableStructureBasedScripts.Add(new SelectRowIntoVariablesGenerator());
            _tableStructureBasedScripts.Add(new TableFunctionGenerator());

            _tableDataBasedScripts = new List<IScriptGenerator>();
            _tableDataBasedScripts.Add(new CaseBlockGenerator());
            _tableDataBasedScripts.Add(new TableDataScriptGenerator());
        }

        /// <summary>
        /// Returns the singleton instance of the ScriptGeneratorManager
        /// </summary>
        public static ScriptGeneratorManager Instance
        {
            get
            {
                if (_instance == null) _instance = new ScriptGeneratorManager();
                return _instance;
            }
        }

        /// <summary>
        /// Property which provides a list of <see cref="IScriptGenerator"/> objects which 
        /// are categrozed as table structure based scripts.
        /// </summary>
        public List<IScriptGenerator> TableStructureBasedScripts
        {
            get
            {
                return _tableStructureBasedScripts;
            }
        }

        /// <summary>
        /// Property which provides a list of <see cref="IScriptGenerator"/> objects which 
        /// are categrozed as table data based scripts.
        /// </summary>
        public List<IScriptGenerator> TableDataBasedScripts
        {
            get
            {
                return _tableDataBasedScripts;
            }
        }

    }

}
